package com.clz.latte.ec.main.sort.content;

import android.support.v7.widget.AppCompatImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseSectionQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.clz.latte.ec.R;
import com.clz.latte.ec.entity.sort.SectionBean;

import java.util.List;

/**
 * Created by Administrator on 2018/4/17.
 */

public class SortContentListAdapter extends BaseSectionQuickAdapter<SectionBean, BaseViewHolder> {
    private static final RequestOptions OPTIONS = new RequestOptions()
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .dontAnimate();

    public SortContentListAdapter(int layoutResId, int sectionHeadResId, List<SectionBean> data) {
        super(layoutResId, sectionHeadResId, data);
    }

    @Override
    protected void convertHead(BaseViewHolder helper, SectionBean item) {
        helper.setText(R.id.header, item.header);
        helper.setVisible(R.id.more, true);
        helper.addOnClickListener(R.id.more);
    }

    @Override
    protected void convert(BaseViewHolder helper, SectionBean item) {
        helper.setText(R.id.tv, item.t.getGoods_name());
        AppCompatImageView iv = helper.getView(R.id.iv);
        Glide.with(mContext)
                .load(item.t.getGoods_thumb())
                .apply(OPTIONS)
                .into(iv);
    }
}
